//
//  RegisterViewController.m
//  LoginAndRegister
//
//  Created by 苗钧豪 on 16/7/15.
//  Copyright © 2016年 苗钧豪. All rights reserved.
//

#import "RegisterViewController.h"

@interface RegisterViewController ()<UITextFieldDelegate>

@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor yellowColor];
    self.navigationController.navigationBarHidden = YES;
    
    // 创建数组，储存每个textfield对应的placeholder
    NSArray *array = @[@"请输入账号",@"请输入密码",@"请确认密码",@"请输入手机号",@"请输入邮箱"];
    // 遍历创建textfield
    for (int i = 0; i < 5; i++) {
        UITextField *textField1 = [[UITextField alloc]initWithFrame:CGRectMake(30, (80+(i+1)*60), 315, 40)];
        textField1.placeholder = array[i];
        textField1.borderStyle = (UITextBorderStyleRoundedRect);
    textField1.secureTextEntry = NO;
        textField1.keyboardType = (UIKeyboardTypeDefault);
        [self.view addSubview:textField1];
        textField1.delegate = self;
        // 给密码和确认密码的输入框添加密文输入，给电话的输入框添加电话键盘
        if (i == 1 || i == 2) {
            textField1.secureTextEntry = YES;
            
        }
        if (i == 3) {
            textField1.keyboardType = UIKeyboardTypePhonePad;
        }
    }

    // 添加按钮
    UIButton *button = [UIButton buttonWithType:(UIButtonTypeSystem)];
    button.frame = CGRectMake(150, 450, 55, 40);
    button.backgroundColor = [UIColor cyanColor];
    [button setTitle:@"确定" forState:(UIControlStateNormal)];
    [button addTarget:self action:@selector(back) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:button];
}
// 按钮执行的方法，模态返回上一个界面
- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
// 回收键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
